

#import "FZ_BoFang_TwoCell_XiangQing_ViewController.h"
#import "FZ_BoFang_TwoCell_XiangQing_Cell_Top.h"
#import "FZ_BoFang_TwoCell_XiangQing_Cell_Low.h"
#import "BaseHeader.h"
#import "FZ_RootModelR.h"
#import "FZ_RightCreatViewDongH.h"
#import "FZ_BoFang_Two_ViewController.h"
@interface FZ_BoFang_TwoCell_XiangQing_ViewController ()<UITableViewDataSource,UITableViewDelegate,buttonIsSelectedDelegate>
@property (nonatomic , retain) UITableView *tableViewBackdrop;
@property (nonatomic ,retain) UIView *viewMeiShiLow;
@property (nonatomic ,retain) UIView *viewMeiShiTop;
@property (nonatomic, retain) UITapGestureRecognizer *tap;
@property (nonatomic, retain) UITapGestureRecognizer *tapFenXiang;
@property (nonatomic, retain) UITapGestureRecognizer *tapSouCang;
@property (nonatomic, retain) UILabel *lanelFenXiang;
@property (nonatomic, retain) UILabel *lanelShouCang;
@property (nonatomic, retain) UITapGestureRecognizer *tapTouXiang;
@end

@implementation FZ_BoFang_TwoCell_XiangQing_ViewController
- (void)dealloc
{
    [_lanelShouCang release];
    [_lanelFenXiang release];
    [_tapSouCang release];
    [_tapFenXiang release];
    [_tap release];
    [_viewMeiShiTop release];
    [_viewMeiShiLow release];
    [_tableViewBackdrop release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
    FZ_RightCreatViewDongH *CreatView = [[FZ_RightCreatViewDongH alloc] initWithFrame:CGRectMake(0, 0, 36.f, 36.f)];
    self.tapTouXiang = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTouXiang:)];
    [CreatView addGestureRecognizer:self.tapTouXiang];
    [_tapTouXiang release];
    
    self.tableViewBackdrop = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableViewBackdrop.delegate = self;
    self.tableViewBackdrop.dataSource = self;
    [self.view addSubview:self.tableViewBackdrop];
    [_tableViewBackdrop release];
    [_tableViewBackdrop registerClass:[FZ_BoFang_TwoCell_XiangQing_Cell_Top class] forCellReuseIdentifier:@"FZ_BoFang_TwoCell_XiangQing_Cell_Top"];
    UINib *nibLow = [UINib nibWithNibName:@"FZ_BoFang_TwoCell_XiangQing_Cell_Low" bundle:[NSBundle mainBundle]];
    UINib *nibTop = [UINib nibWithNibName:@"FZ_BoFang_TwoCell_XiangQing_Cell_Top" bundle:[NSBundle mainBundle]];
    [self.tableViewBackdrop registerNib:nibLow forCellReuseIdentifier:@"FZ_BoFang_TwoCell_XiangQing_Cell_Low"];
    [self.tableViewBackdrop registerNib:nibTop forCellReuseIdentifier:@"FZ_BoFang_TwoCell_XiangQing_Cell_Top"];
    [self CreatView];
    [self CreatTap];
    [self creatLabel];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 55.f;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    //    if (self.arrsubject.count != 0) {
    //        return (self.arrsubject.count + 2);
    //    }
   
        return self.jieShouArray.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    if (indexPath.row == 0) {
//        FZ_BoFang_TwoCell_XiangQing_Cell_Top *cellTop = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_TwoCell_XiangQing_Cell_Top"];
//        cellTop.selectionStyle = UITableViewCellSelectionStyleNone;
    //        return cellTop;
    //    }
    //    else{
    FZ_BoFang_TwoCell_XiangQing_Cell_Low *cellLow = [tableView dequeueReusableCellWithIdentifier:@"FZ_BoFang_TwoCell_XiangQing_Cell_Low"];
    cellLow.delegateIsSelected = self;
//    cellLow.backgroundColor = [UIColor orangeColor];
    FZ_RootModelR *model = self.jieShouArray[indexPath.row];
    cellLow.JieShouModel = model;
    cellLow.selectionStyle = UITableViewCellSelectionStyleNone;
    return cellLow;
    //    }
}

- (void)CreatView
{
    self.viewMeiShiLow = [[UIView alloc] initWithFrame:CGRectMake(230.f  , - self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
    self.viewMeiShiLow.userInteractionEnabled = YES;
    self.viewMeiShiLow.backgroundColor = [UIColor blackColor];
    self.viewMeiShiLow.alpha = 0.6f;
    [self.view addSubview:self.viewMeiShiLow];
    [_viewMeiShiLow release];
    
    self.viewMeiShiTop = [[UIView alloc] initWithFrame:CGRectMake(230.f , - self.view.frame.size.height, self.view.frame.size.width, 60.f)];
    self.viewMeiShiTop.userInteractionEnabled = YES;
    self.viewMeiShiTop.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.viewMeiShiTop];
    [_viewMeiShiTop release];
}

- (void)buttonIsSelected:(NSArray *)array{
    [UIView animateWithDuration:0.7 animations:^{
        self.viewMeiShiLow.frame = CGRectMake(0, 0 , self.tableViewBackdrop.frame.size.width, self.tableViewBackdrop.frame.size.height);
        self.viewMeiShiTop.frame = CGRectMake(0, self.tableViewBackdrop.frame.size.height - 120.f , self.tableViewBackdrop.frame.size.width, 140.f);
    }];
}

- (void)tapAnimateView:(UITapGestureRecognizer *)sender{
    [UIView animateWithDuration:0.7 animations:^{
        self.viewMeiShiLow.frame = CGRectMake(230.f  , - self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
        self.viewMeiShiTop.frame = CGRectMake(230.f , - self.view.frame.size.height, self.view.frame.size.width, 60.f);
    }];
}

- (void)CreatTap{
    self.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAnimateView:)];
    [self.viewMeiShiLow addGestureRecognizer:self.tap];
    [_tap release];
    self.tapFenXiang = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFenXiang:)];
    [self.lanelFenXiang addGestureRecognizer:self.tapFenXiang];
    [_tapFenXiang release];
    self.tapSouCang = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapSouCang:)];
    [self.lanelShouCang addGestureRecognizer:self.tapSouCang];
    [_tapSouCang release];
}

- (void)creatLabel{
    self.lanelFenXiang = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.viewMeiShiTop.frame.size.width, 40.f)];
    self.lanelFenXiang.text = @"分享";
    self.lanelFenXiang.userInteractionEnabled = YES;
    self.lanelFenXiang.backgroundColor = [UIColor yellowColor];
    [self.viewMeiShiTop addSubview:self.lanelFenXiang];
    [_lanelFenXiang release];
    self.lanelShouCang = [[UILabel alloc] initWithFrame:CGRectMake(0, self.lanelFenXiang.frame.size.height, self.viewMeiShiTop.frame.size.width, self.lanelFenXiang.frame.size.height)];
    self.lanelShouCang.text = @"收藏";
    self.lanelShouCang.userInteractionEnabled = YES;
    [self.viewMeiShiTop addSubview:self.lanelShouCang];
    self.lanelShouCang.backgroundColor = [UIColor orangeColor];
    [_lanelShouCang release];
}

- (void)tapFenXiang:(UITapGestureRecognizer *)sender{

    CGPoint touchPoint = [sender locationInView:self.viewMeiShiTop];
    if ([self.viewMeiShiTop.layer.presentationLayer hitTest:touchPoint]) {

    }
}

- (void)tapSouCang:(UITapGestureRecognizer *)sender{

}

- (void)leftBarButtonAction:(UIBarButtonItem *)sender{
    [self.navigationController popViewControllerAnimated:YES];
//    self.tabBarController.tabBar.hidden
}

- (void)tapTouXiang:(UITapGestureRecognizer *)sender{
    FZ_BoFang_Two_ViewController *boFangTwo = [[FZ_BoFang_Two_ViewController alloc] init];
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
    [self.navigationController pushViewController:boFangTwo animated:YES];
    [boFangTwo release];
}

@end
